package com.bw.lyc.mvp.model.entity;

import com.bw.lyc.mvp.base.model.BaseEntity;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

/**
 *{\"live_id\":1,\"live_time\":1622460911,
 * \"live_img\":\"123.jpg\",\"live_title\":\"测试1\",
 * \"live_url\":\"http:\/\/ivi.bupt.edu.cn\/hls\/cctv1hd.m3u8\",
 * \"live_fabulous\":10}
 * */

public class LiveEntity extends BaseEntity {

    public String values;

    public List<Values> getValues() {
        if (values == null)
            return null;
        List<Values> list = new ArrayList<>();
        try {
            JSONArray jsonArray = new JSONArray(values);
            for (int i = 0;i < jsonArray.length();i ++){
                String str = jsonArray.getString(i);
                Values entity = new Gson().fromJson(str,Values.class);
                list.add(entity);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return list;
    }

    public static class Values{
        public long live_id;
        public long live_time;
        public String live_img;
        public String live_title;
        public String live_url;
        public int live_fabulous;
    }

}